package com.study;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @ClassName DateUtils
 * @Description TODO
 * @Author ThinkPad
 * @Date 2020/10/25 22:15
 * @Version 1.0
 **/
public class DateUtils {
    public static String date2String(Date date, String pattern) {
        DateFormat dateFormat = new SimpleDateFormat(pattern);
        String dateStr = dateFormat.format(date);
        return dateStr;
    }

    public static Date date2String(String date, String pattern) throws ParseException {
        DateFormat dateFormat = new SimpleDateFormat(pattern);
        Date dateP = dateFormat.parse(date);
        return dateP;
    }

}
